package com.ruixi.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruixi.entity.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author lrzg
 * @date 2021-10-18 11:20
 * @Description TODO
 */
@Repository
public interface UserMapper extends BaseMapper<User> {
    public List<User> findAllUser();

    @Select("SELECT * from user where id=#{id}")
    User getById(Long id);

    User getUserByName(@Param("name") String name);

    List<User> getUserListByName(@Param("name") String name);

    @Update("update user set username = #{username}, address =#{address} where id = #{id}")
    int updateUser(User userInfo);

    @Insert("insert into user (username,birthday,sex,address) values ( #{username},#{birthday},#{sex},#{address})")
    int saveUser(User user);

    @Delete("delete from user where id = #{id}")
    int deleteUserById(Long id);
}
